package com.chenyaowei.web.controller.payment;

import com.chenyaowei.common.annotation.Log;
import com.chenyaowei.common.core.controller.BaseController;
import com.chenyaowei.common.core.domain.AjaxResult;
import com.chenyaowei.common.core.page.TableDataInfo;
import com.chenyaowei.common.enums.BusinessType;
import com.chenyaowei.common.utils.poi.ExcelUtil;
import com.chenyaowei.payment.domain.CywPaymentInfo;
import com.chenyaowei.payment.service.ICywPaymentInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 支付信息Controller
 * 
 * @author 陈耀威
 * @date 2023-12-03
 */
@RestController
@RequestMapping("/payment/paymentInfo")
public class CywPaymentInfoController extends BaseController
{
    @Autowired
    private ICywPaymentInfoService cywPaymentInfoService;

    /**
     * 查询支付信息列表
     */
    @PreAuthorize("@ss.hasPermi('payment:paymentInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CywPaymentInfo cywPaymentInfo)
    {
        startPage();
        List<CywPaymentInfo> list = cywPaymentInfoService.selectCywPaymentInfoList(cywPaymentInfo);
        return getDataTable(list);
    }

    /**
     * 导出支付信息列表
     */
    @PreAuthorize("@ss.hasPermi('payment:paymentInfo:export')")
    @Log(title = "支付信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CywPaymentInfo cywPaymentInfo)
    {
        List<CywPaymentInfo> list = cywPaymentInfoService.selectCywPaymentInfoList(cywPaymentInfo);
        ExcelUtil<CywPaymentInfo> util = new ExcelUtil<CywPaymentInfo>(CywPaymentInfo.class);
        util.exportExcel(response, list, "支付信息数据");
    }

    /**
     * 获取支付信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('payment:paymentInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cywPaymentInfoService.selectCywPaymentInfoById(id));
    }

    /**
     * 新增支付信息
     */
    @PreAuthorize("@ss.hasPermi('payment:paymentInfo:add')")
    @Log(title = "支付信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CywPaymentInfo cywPaymentInfo)
    {
        return toAjax(cywPaymentInfoService.insertCywPaymentInfo(cywPaymentInfo));
    }

    /**
     * 修改支付信息
     */
    @PreAuthorize("@ss.hasPermi('payment:paymentInfo:edit')")
    @Log(title = "支付信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CywPaymentInfo cywPaymentInfo)
    {
        return toAjax(cywPaymentInfoService.updateCywPaymentInfo(cywPaymentInfo));
    }

    /**
     * 删除支付信息
     */
    @PreAuthorize("@ss.hasPermi('payment:paymentInfo:remove')")
    @Log(title = "支付信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cywPaymentInfoService.deleteCywPaymentInfoByIds(ids));
    }
}
